package com.lldpet.spring.cloud.demo.stream.demo.service.impl;

import com.lldpet.spring.cloud.demo.stream.demo.channel.BpsSource;
import com.lldpet.spring.cloud.demo.stream.demo.service.MessageProvider;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;

/**
 * @desc：MessageProviderImpl
 * @author: llduo
 * @date: 2021/5/11 16:51
 * @version:
 * @since:
 *
 */
/**
 * 定义消息的推送 channel
 * @author llduo
 */
@EnableBinding(Source.class)
public class MessageProviderImpl implements MessageProvider {

    /**
     * 消息发送管道
     */
    @Resource
    private MessageChannel output;


    @Override
    public String send() {
        String msg = "消息生产者-发送消息";
        output.send(MessageBuilder.withPayload(msg).build());
        return msg;
    }
}
